home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / manage / snmp / kip / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-17  |  3.1 KB  |  133 lines

  1. /*
  2.  * Initialize data structures that might otherwise be initialized
  3.  * at compile time, but for re-startable RAM code, must be at run-time.
  4.  *
  5.  * (c) Copyright 1986, Kinetics, Inc.
  6.  * May be used but not sold without permission.
  7.  *
  8.  * $Header: init.c,v 4.1 88/11/01 19:49:58 sw0l Locked $
  9.  */
  10.  
  11. #include "gw.h"
  12. #include "fp/pbuf.h"
  13. #include "ab.h"
  14. #include "ether.h"
  15. #include "inet.h"
  16. #include "ie.h"
  17. #include "gwctl.h"
  18. #include "fp/cmdmacro.h"
  19.  
  20. #include "glob.h"
  21.  
  22. /* from ie.c */
  23. /*
  24.  * Configuration command data (from page 4-5 of NI3210 manual).
  25.  */
  26. struct cb ieconf_proto = {
  27.   SWAB(0),            /* status */
  28.   SWAB(CB_EL|CBC_CONFIG),    /* cmd */
  29.   SWAB(0xffff),            /* link to next (none) */
  30.   SWAB(0x020c),            /* FIFO thresshold is 2 */
  31.                 /* 12 byte parameter list */
  32.   SWAB(0x2ec0),            /* 8 byte preamble */
  33.                 /* address and data type in data */
  34.                 /* 6 ethernet address bytes */
  35.                 /* store bad frames in memory */
  36.                 /* srdy/ardy pin opertes as srdy */
  37.   SWAB(0x6000),            /* 0x60 Interframe spacing in TxC time units */
  38.                 /* 802.3 Exponential Backoff */
  39.   SWAB(0xf200),            /* 16 retries on xmit collision */
  40.                 /* slot time: 0x200 */
  41.   SWAB(0x0400),            /* Collision Detect Source: external */
  42.                 /* Carrier Sense Source: external */
  43.                 /* No padding */
  44.                 /* Bitstuffing: End of carrier (802.3) */
  45.                 /* CRC: 32 bit CCITT II CRC polyn. */
  46.                 /* CRC Insertion */
  47.                 /* No Xmit on no carrier */
  48.                 /* NRZ encoding/decoding */
  49.                 /* Broadcast allowed */
  50.                 /* Normal (vs. promiscuous) mode */
  51.                 /* Unclear what bit 10 on does */
  52.   SWAB(0x003C)            /* min pkt size to 60 (was 64) */
  53. };
  54.  
  55. /* from send.c */
  56. extern short dlen;
  57. extern char outbuf[];
  58. u_char lap_head[3];
  59. u_char atwr_diag[1];
  60.  
  61.  
  62. struct fp_atwrite atwr_proto[] = {
  63.     3, (u_char *) lap_head,
  64.     2, (u_char *) &dlen,
  65.     1, (u_char *) atwr_diag,
  66.     0, (u_char *) outbuf,
  67.     0, (u_char *) 0
  68. };
  69.  
  70. struct fp_proelem elem[1];
  71. struct fp_protect prot;
  72.  
  73. data_init()
  74. {
  75.     /* from gw.c */
  76.     extern struct ifnet ifie_proto, ifab_proto, ifet_proto;
  77.     /* EtherTalk address aquisition variables */
  78.     extern iaddr_t et_probe;
  79.     extern short et_probe_count;
  80.  
  81.     /* from ie.c */
  82.     extern struct cb xmit;
  83.     extern struct cb iasetup;
  84.     extern struct cb ieconfig;
  85.     /* from send.c */
  86.     extern struct fp_atwrite the_pkt[];
  87.     register struct fp_atwrite *ap,*bp;
  88.  
  89.     /* from gw.c */
  90.     ddpWKSUnix = defddpWKSUnix;
  91.     ifie = ifie_proto;
  92.     ifab = ifab_proto;
  93.     ifet = ifet_proto;
  94.     msclock = 0;
  95.  
  96.     et_probe = 0;
  97.     ((char *)&et_probe)[3] = 0x7f; /* start PROBE's in server range */
  98.     et_probe_count = 0;
  99.  
  100.     /* from ie.c */
  101.     xmit.cb_cmd = SWAB(CB_EL|CB_I|CBC_TRANS);
  102.     iasetup.cb_cmd = SWAB(CB_EL | CBC_IASETUP);
  103.     ieconfig = ieconf_proto;
  104.  
  105.     /* from send.c */
  106.     lap_head[0] = (u_char) 0xFF;
  107.     lap_head[1] = (u_char) 0x00;
  108.     lap_head[2] = (u_char) 'K';
  109.     atwr_diag[0] = 'D';
  110.     ap = the_pkt;
  111.     bp = atwr_proto;
  112.     while (ap < &the_pkt[5]) {
  113.         *ap++ = *bp++;
  114.     }
  115.  
  116. }
  117.  
  118. checksum(begin,dataend)
  119. char *begin;
  120. char *dataend;
  121. {
  122.     /* set up protected ram areas */
  123.     /* beginning of text segment through the end of initialized data */
  124.     elem[0].fpp_memp = begin;
  125.     elem[0].fpp_count = ((int)dataend) - ((int)begin);
  126.  
  127.     /* make the protect call */
  128.     prot.fpt_oper = PR_PROTECT;
  129.     prot.fpt_count = 1;
  130.     prot.fpt_elem = elem;
  131.     K_PROTECT(&prot);
  132. }
  133.